package com.learn.hibernatevalidator.chapter12.booleancomposition;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import jakarta.validation.ReportAsSingleViolation;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import org.hibernate.validator.constraints.CompositionType;
import org.hibernate.validator.constraints.ConstraintComposition;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @author: liyf
 * @create: 2025-01-25 19:45
 **/
@ConstraintComposition(CompositionType.OR)
@Pattern(regexp = "[a-z]")
@Size(min = 2, max = 3)
@ReportAsSingleViolation
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {})
public @interface PatternOrSize {
    String message() default "{com.learn.hibernatevalidator.chapter11." +
            "booleancomposition.PatternOrSize.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
